package dao

import (
	"context"
	"github.com/exam/model"
	"gorm.io/gorm"
)

type UserDao struct {
	db *gorm.DB
}

func (u *UserDao) GetUserByAccount(ctx context.Context, account string) (*model.User, error) {
	var user model.User
	if err := u.db.Select("id,account,pwd").Where("account = ?", account).First(&user).Error; err != nil {
		return nil, err
	}
	return &user, nil
}

func NewUserDao(db *gorm.DB) *UserDao {
	return &UserDao{
		db: db,
	}
}
